#pragma once

class Mutex;
struct lua_State;

struct CMD
{
	std::string m_cmd;
	bool		m_isLine;	

	CMD(const std::string& cmd, bool isLine);
};

class CShell:
	public IShell,
	public IThread
{
public:
	CShell();
	~CShell();

	void AddLuaFunction(const std::string& name, void (*ptn)(const std::string&, int, int, const std::string&));
	void AddLuaFunction(const std::string& name, void (*ptn)(const std::string&, const std::string&));
	void AddLuaFunction(const std::string& name, void (*ptn)(const std::string&));
	void AddLuaFunction(const std::string& name, void (*ptn)());
	void AddLuaFunction(const std::string& name, void (*ptn)(float, float, float, float, char, float));

	void Command(const std::string& cmd);
	void File(const std::string& path);
	void FileNow(const std::string& path);

	void CallFunction(const std::string& name);

private:
	virtual void		OnThreadStart();

	lua_State*						m_luaState;
	
	IMutex*							m_functionsvec_mutex;
	std::vector<const std::string>	m_functionsVector;

	IMutex*							m_commandsvec_mutex;
	std::vector<CMD>				m_commandsVector;

	virtual int			ThreadLoop();

};

